home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / ZU7WQF (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.8 KB  |  76 lines

  1. package com.sun.java.swing.plaf.metal;
  2.  
  3. import com.sun.java.swing.ButtonModel;
  4. import com.sun.java.swing.Icon;
  5. import com.sun.java.swing.JButton;
  6. import com.sun.java.swing.plaf.UIResource;
  7. import java.awt.Color;
  8. import java.awt.Component;
  9. import java.awt.Graphics;
  10. import java.io.Serializable;
  11.  
  12. class MetalIconFactory$InternalFrameMinimizeIcon implements Icon, UIResource, Serializable {
  13.    JButton parentButton;
  14.    ButtonModel buttonModel;
  15.    Color backgroundColor;
  16.    Color titleColor;
  17.    Color edgeColor;
  18.    Color highlightColor;
  19.    Color downRightHighlight;
  20.    Color upLeftHighlight;
  21.    int iconSize = 12;
  22.  
  23.    public MetalIconFactory$InternalFrameMinimizeIcon(int size) {
  24.       this.iconSize = size;
  25.    }
  26.  
  27.    public void paintIcon(Component c, Graphics g, int x, int y) {
  28.       this.parentButton = (JButton)c;
  29.       this.buttonModel = this.parentButton.getModel();
  30.       this.downRightHighlight = MetalLookAndFeel.getPrimaryControlHighlight();
  31.       this.upLeftHighlight = MetalLookAndFeel.getPrimaryControlShadow();
  32.       this.backgroundColor = MetalLookAndFeel.getPrimaryControl();
  33.       this.titleColor = MetalLookAndFeel.getPrimaryControlShadow();
  34.       this.edgeColor = MetalLookAndFeel.getPrimaryControlShadow();
  35.       this.highlightColor = MetalLookAndFeel.getPrimaryControlInfo();
  36.       if (this.parentButton.getClientProperty("paintActive") != Boolean.TRUE) {
  37.          this.downRightHighlight = MetalLookAndFeel.getControlHighlight();
  38.          this.upLeftHighlight = MetalLookAndFeel.getControlShadow();
  39.          this.backgroundColor = MetalLookAndFeel.getControl();
  40.          this.titleColor = MetalLookAndFeel.getControlShadow();
  41.          this.edgeColor = MetalLookAndFeel.getControlShadow();
  42.       } else if (this.buttonModel.isPressed() && this.buttonModel.isArmed()) {
  43.          this.backgroundColor = MetalLookAndFeel.getPrimaryControlShadow();
  44.          this.titleColor = MetalLookAndFeel.getPrimaryControlDarkShadow();
  45.          this.edgeColor = MetalLookAndFeel.getPrimaryControlInfo();
  46.       }
  47.  
  48.       int twoThirds = this.iconSize * 2 / 3;
  49.       int var10000 = this.iconSize * 3 / 4;
  50.       g.translate(x, y);
  51.       g.setColor(this.backgroundColor);
  52.       g.fillRect(0, 0, this.iconSize, this.iconSize);
  53.       g.setColor(this.downRightHighlight);
  54.       g.drawLine(1, this.iconSize - 1, this.iconSize - 1, this.iconSize - 1);
  55.       g.drawLine(this.iconSize - 1, 1, this.iconSize - 1, this.iconSize - 1);
  56.       g.setColor(this.upLeftHighlight);
  57.       g.drawLine(0, 0, 0, this.iconSize - 2);
  58.       g.drawLine(0, 0, this.iconSize - 2, 0);
  59.       g.setColor(this.edgeColor);
  60.       g.drawRect(1, 1, this.iconSize - 3, this.iconSize - 3);
  61.       g.setColor(this.titleColor);
  62.       g.fillRect(1, twoThirds, this.iconSize - 3, this.iconSize - twoThirds - 2);
  63.       g.setColor(this.highlightColor);
  64.       g.drawRect(1, twoThirds, this.iconSize - 3, this.iconSize - twoThirds - 2);
  65.       g.translate(-x, -y);
  66.    }
  67.  
  68.    public int getIconWidth() {
  69.       return this.iconSize;
  70.    }
  71.  
  72.    public int getIconHeight() {
  73.       return this.iconSize;
  74.    }
  75. }
  76.